#! /bin/bash
export LANG=zh_CN.UTF-8
PRESTO_HOME=/export/server/presto/bin/presto


${PRESTO_HOME} --catalog hive --server 192.168.88.80:8090 --execute "

-- 如果使用Hive，因采用了动态分区插入技术，需要调参
-- 本次考勤主题 没有拉链操作 使用presto操作，无需设置参数

-- ------------------因为采用了动态分区插入技术 因此需要设置相关参数---------------
-- --分区
-- SET hive.exec.dynamic.partition=true;
-- SET hive.exec.dynamic.partition.mode=nonstrict;
-- set hive.exec.max.dynamic.partitions.pernode=10000;
-- set hive.exec.max.dynamic.partitions=100000;
-- set hive.exec.max.created.files=150000;
-- --hive压缩
-- set hive.exec.compress.intermediate=true;
-- set hive.exec.compress.output=true;
-- --写入时压缩生效
-- set hive.exec.orc.compression.strategy=COMPRESSION;

--=================增量表，只会新增不会更新=================
-- 学生打卡记录表
insert into hive.edu_online_dwd.fact_tbh_student_signin_record
select id,
       normal_class_flag,
       time_table_id,
       class_id,
       student_id,
       substring(signin_time,12,8) as signin_time,
       inner_flag,
       signin_type,
       share_state,
       inner_ip,
       signin_date
from hive.edu_online_ods.tbh_student_signin_record;

--=================全量覆盖=================
-- 学生请假申请表
insert into hive.edu_online_dwd.fact_student_leave_apply
select
    id,
    class_id,
    student_id,
    audit_state,
    audit_person,
    audit_time,
    audit_remark,
    leave_type,
    leave_reason,
    begin_time,
    begin_time_type,
    end_time,
    end_time_type,
    days,
    cancel_state,
    cancel_time,
    old_leave_id,
    leave_remark,
    valid_state,
    create_time
from hive.edu_online_ods.student_leave_apply;"